<template>
	<view>
		<view class="p30">
			<view class="flex">
				<u-avatar :src="data.avatar" size="60"></u-avatar>
				<view class="ml20 flex1 u-line-1">{{data.name}}</view>
			</view>
			<!-- 总下单数 服务次数 就诊人数 -->
			<view class="flex row-between mt20">
				<view class="">
					<text>总下单数</text>
					<text class="fs30 fw-w ml10">{{data.order_num}}</text>
				</view>
				<view class="">
					<text>服务次数</text>
					<text class="fs30 fw-w ml10">{{data.service_num}}</text>
				</view>
				<view class="" @click="$jump('/pages/my/addPatient/patientList',$params)">
					<text>就诊人数</text>
					<text class="fs30 fw-w ml10">{{data.patient_num}}</text>
				</view>
			</view>
			<view class="color-999 fs26 mt20">最后下单时间： {{data.pay_time}}</view>
		</view>
		<u-tabs :isScroll="false" :list="tabs" :current="current" @change="change" :active-color="$zs"></u-tabs>
		<view class="p30 bg-fff">
			<block v-for="(item,index) in tabs" :key="index">
				<block v-if="item.type==c_data.type">
					<view class="" v-if="c_data.type==1">
						<view class="w90 h90 radius pf right30 bottom100 flex-col col-center row-center z-index2 bg-fff"
							@click="$jump('/pages/my/client/add_log',$params)"
							style="box-shadow: 0rpx 1.2rpx 10rpx 0rpx rgba(0, 0, 0,.3);">
							<view>新建</view>
							<view>记录</view>
						</view>

						<u-empty v-if="item.list&&item.list.length==0" marginTop="100"></u-empty>
						<view class="pt20 pb20" v-for="(item2,index2) in item.list" :key="index2">
							<view class="fw-w  w-max flex row-between">
								<view class="">{{item2.create_time}}</view>
								<view class="">
									<u-button size="mini" type="warning" v-if="item2.type=='my'"
										@click="$jump('/pages/my/client/add_log',{...$params,id:item2.id})">
										编辑</u-button>
								</view>
							</view>
							<view class="mt20">{{item2.remarks}}</view>
							<view class="h20"></view>
							<z-imgs :paths="item2.images" look margin="20" radius="10" />
						</view>
					</view>
					<view class="" v-else-if="c_data.type==2">
						<view class="w90 h90 radius pf right30 bottom100 flex-col col-center row-center z-index2 bg-fff"
							@click="$jump('/pages/my/client/addOrder',$params)"
							style="box-shadow: 0rpx 1.2rpx 10rpx 0rpx rgba(0, 0, 0,.3);">
							<view>新建</view>
							<view>订单</view>
						</view>

						<orderList :list="item.list"></orderList>
					</view>
					<view class="" v-else-if="c_data.type==3">
						<view class="fw-w fs32">基本信息</view>
						<view class="pt20 pb20 flex row-between">
							<view class="color-999">姓名</view>
							<view class="">{{data.name}}</view>
						</view>
						<view class="pt20 pb20 flex row-between">
							<view class="color-999">手机号</view>
							<view class="">{{data.mobile}}</view>
						</view>
						<!-- <view class="pt20 pb20 flex row-between">
							<view class="color-999">地区</view>
							<view class="">地区</view>
						</view> -->
						<view class="pt20 pb20 flex row-between" v-if="data.address">
							<view class="color-999">详细地址</view>
							<view class="">{{data.address}}</view>
						</view>
						<view class="pt20 pb20 flex row-between" @click="$jump('/pages/my/address/address',$params)">
							<view class="fw-w fs32">收货地址</view>
							<view class="">
								<u-icon name="arrow-right"></u-icon>
							</view>
						</view>
						<view class="pt20 pb20 flex row-between"
							@click="$jump('/pages/my/addPatient/patientList',$params)">
							<view class="fw-w fs32">就诊人</view>
							<view class="">
								<u-icon name="arrow-right"></u-icon>
							</view>
						</view>
						<!-- 	<view class="fw-w fs32 mt20">就诊人信息</view>
						<view class="pb20 border-b">
							<view class="pt20 pb20 flex row-between">
								<view class="color-999">就诊姓名</view>
								<view class="">张小小</view>
							</view>
							<view class="pt20 pb20 flex row-between">
								<view class="color-999">性别</view>
								<view class="">男</view>
							</view>
							<view class="pt20 pb20 flex row-between">
								<view class="color-999">出生日期</view>
								<view class="">出生日期</view>
							</view>
							<view class="pt20 pb20 flex row-between">
								<view class="color-999">就诊人关系</view>
								<view class="">本人</view>
							</view>
							<view class="pt20 pb20 flex row-between">
								<view class="color-999">就诊人身份证号</view>
								<view class="">41072419******0015</view>
							</view>
						</view> -->
					</view>
				</block>
			</block>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				tabs: [{
						name: '往来记录',
						type: 1
					},
					{
						name: '历史订单',
						type: 2,
						list: [],
						page: 1
					},
					{
						name: '基本资料',
						type: 3
					},
				],
				data: '',

			};
		},
		computed: {
			c_data() {
				return this.tabs[this.current]
			}
		},
		onShow() {
			this.getData()
			this.change(this.current)
		},
		onReachBottom() {
			this.historyOrder('down')
		},
		methods: {
			getData() {
				this.$request('/master/customer/customerInfo', this.$params).then(res => {
					this.data = res.data
				})
			},
			change(e) {
				this.current = e
				if (this.c_data.type == 2) {
					this.historyOrder(e)
				} else if (this.c_data.type == 1) {
					this.logList(e)
				}
			},
			historyOrder(e) {
				let data = this.c_data
				e == 'down' ? data.page++ : data.page = 1
				let params = {
					...this.$params,
					page: data.page,
				}
				this.$request('/master/customer/historyOrder', params).then(res => {
					let list = res.data.data
					e == 'down' ? data.list.push(...list) : data.list = list
				})
			},
			logList(e) {
				let data = this.c_data
				e == 'down' ? data.page++ : data.page = 1
				let params = {
					...this.$params,
					page: data.page,
				}
				this.$request('/master/customer/logList', params).then(res => {
					let list = res.data.data
					e == 'down' ? data.list.push(...list) : data.list = list
				})
			},

		}
	}
</script>

<style lang="scss">

</style>